<template>
  <div class="table-page-search-wrapper">
    <el-form :inline="true" ref="form" :model="form">
      <el-row :gutter="16">
        <el-col :span="6">
          <el-form-item label="栏目" prop="areaName">
            <column-select
              ref="columnSelect"
              :selectValue="form.categoryId"
              v-model="form.categoryId"
              @select="handleDeptSelect"
            />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="6">
          <el-form-item label="名称">
            <el-input v-model="form.articleName" placeholder="输入文章名称搜索" />
          </el-form-item>
        </el-col>-->
        <el-col :span="6">
          <el-form-item label="关键字" prop="content">
            <el-input v-model="form.content" placeholder="输入内容搜索" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item>
            <el-tooltip class="item" effect="dark" content="查询" placement="top">
              <el-button type="primary" class="mr20" @click="handleSearch" icon="el-icon-search" />
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="重置" placement="top">
              <el-button @click="handleReset" icon="el-icon-refresh-right" />
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import ColumnSelect from '../column/ColumnSelect'

export default {
  components: {
    ColumnSelect
  },
  data() {
    return {
      form: {
        categoryId: null,
        pageNo: 1
      }
    }
  },
  methods: {
    handleSearch() {
      this.$emit('search', this.form)
    },
    handleReset() {
      this.$set(this.form, 'categoryId', null)
      this.$refs.columnSelect.reset()
      this.$refs.form.resetFields()
      this.$emit('search', this.form)
    },
    handleDeptSelect(value) {
      console.log('value', value)

      this.$set(this.form, 'categoryId', value.id)
    }
  }
}
</script>
